from django.db.models import QuerySet, Q

from server.apps.main.models import Todo


def list_all() -> QuerySet[Todo]:
    """Returns all BlogPosts that are ready to be published."""
    return Todo.objects.order_by('id')

def search(text) -> QuerySet[Todo]:
    return Todo.objects.filter(Q(title__contains=text) | Q(description__contains=text)).order_by('id')

def show_one(task_id) -> QuerySet[Todo]:
    return Todo.objects.get(id=task_id)